<?php
/**
 * Created by PhpStorm
 * @Author: wangwin
 * @Date: 2024/8/12
 * @Time: 9:25
 * @Version: 1.0
 */

namespace App\Jobs;

use App\Service\PaperService;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;

class SyncPaperDataJob implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;


    /**
     * The number of seconds the job can run before timing out.
     *
     * @var int
     */
    public $timeout =600;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    protected $data = [];

    public function __construct($data)
    {
        $this->data = $data;
    }

    /**
     * 队列
     * @return bool
     * @throws \Illuminate\Contracts\Container\BindingResolutionException
     */
    public function handle()
    {
        [$paperIds] = $this->data;
        /** @var  PaperService $paperService */
        $paperService = app()->make(PaperService::class);

        return $paperService->syncPaperData($paperIds);

    }
}